package org.jeecg.modules.demo.hd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.jeecg.modules.demo.hd.entity.AppMyProject;
import org.jeecg.modules.demo.hd.mapper.AppMyProjectMapper;
import org.jeecg.modules.demo.hd.service.IAppMyProjectService;
import org.jeecg.modules.demo.hd.vo.myProject.MyProjectModelVo;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.List;

/**
 * @Description: app_my_project
 * @Author: jeecg-boot
 * @Date: 2025-04-16
 * @Version: V1.0
 */
@Service
public class AppMyProjectServiceImpl extends ServiceImpl<AppMyProjectMapper, AppMyProject> implements IAppMyProjectService {

    @Override
    public List<MyProjectModelVo> getMyProjectList(String userId) {
        return baseMapper.getMyProjectList(userId);
    }

    @Override
    public boolean haveState(String userId, String project_id) {
        LambdaQueryWrapper<AppMyProject> lambdaQueryWrapper = Wrappers.lambdaQuery();
        lambdaQueryWrapper.eq(AppMyProject::getUserId, userId)
                .eq(AppMyProject::getProjectId, project_id);
        List<AppMyProject> appMyProjects = this.baseMapper.selectList(lambdaQueryWrapper);
        if (appMyProjects != null && appMyProjects.size() > 0) {
            return true;
        }
        return false;
    }


}
